/*
  MinCC - Minimalist Compiler Collection
  Copyright (C) 2009 Scott Lawrence

  MinCC is free software: you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  MinCC is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  License for more details.

  You should have received a copy of the GNU General Public License
  along with mincc.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
  Note that this file is neither a true header nor a true source file.
  It is the head node of the testing suite, which is not build as a
  separate program but rather as a supplement to the main program.
  The file main.cpp includes this file, and this file includes other
  files with relevant code.
*/

#include <string.h>
#include "../fileLoader.hpp"

int loader_init() {
    return 0;
}

int loader_cleanup() {
    return 0;
}


void test_fileLoader_general() {
    FileLoader *loader=new FileLoader();
    CU_ASSERT(loader!=0);
    delete loader;
    CU_PASS("Loader created and deleted successfully");
    const char *path=".:/dev/shm";
    loader=new FileLoader(path);
    CU_ASSERT(strcmp(loader->getPath(),path)==0);
    delete loader;
}

void test_fileLoader_path() {
    FileLoader *loader=new FileLoader();
    CU_ASSERT(strlen(loader->getPath())>0);
    delete loader;
    const char *path=".:/dev/shm";
    loader=new FileLoader(path);
    CU_ASSERT(strcmp(loader->getPath(),path)==0);
    loader->setPath("..:.");
    CU_ASSERT(strcmp(loader->getPath(),"..:.")==0);
    loader->addToPath("/dev/shm");
    CU_ASSERT(strcmp(loader->getPathList()[0],"..")==0);
    CU_ASSERT(strcmp(loader->getPath(),"..:.:/dev/shm")==0);
    delete loader;
}

void test_fileLoader_fs() {

}


void create_loader_tests() {
    CU_pSuite suite=CU_add_suite("Loader",loader_init,loader_cleanup);
    CU_add_test(suite,"FileLoader General",test_fileLoader_general);
    CU_add_test(suite,"FileLoader Path",test_fileLoader_path);
    CU_add_test(suite,"FileLoader Filesystem",test_fileLoader_fs);
}
